/**
 * Created by claim on 17-3-12.
 */
let Random = (max, callback) => {
    try {
        let num = Math.random() * parseInt(max);
        callback(null, num);
    } catch (e) {
        callback(e);
    }
};

Random(4, (err, num) => {
    if (err) {
        console.log(err);
    } else {
        console.log(num);
    }
});

Random("aa", (err, num) => {
    if (err) {
        console.log(err);
    } else {
        console.log(num);
    }
});
